package com.skaz.security;

import lombok.Data;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * @Author: jungle
 * @Date: 2018/11/8 11:24 AM
 */
@Data
public class SecurityAuthentication extends AbstractAuthenticationToken {

    private String token;

    private UserDetails userDetails;


    public SecurityAuthentication(String token, UserDetails userDetails) {
        super(userDetails.getAuthorities());
        this.token = token;
        this.userDetails = userDetails;
        super.setAuthenticated(true);
    }


    public Object getCredentials() {
        return this.token;
    }

    public Object getPrincipal() {
        return this.userDetails;
    }
}
